const app = new require('koa')()//use(); ctx.request|response
const views = require('koa-views');//ctx.render('*.ejs',{})
const static = require('koa-static');
const router = new require('koa-router')()
const bodyParser = require('koa-bodyparser')//新增ctx.request.body

app.use(async (ctx, next) => {
  await next();
})

app.use(bodyParser())
//koa-view
app.use(views(path.join(__dirname, './view'), {extension: 'ejs'}));// 可用ctx.render('test.ejs',{title:'title_zjy'})
//koa-static
app.use(static(path.join(__dirname, './public')));
//koa-router
app.use(router.routes());app.use(router.allowedMethods());
router.get||post('/xxx', async (ctx, next) => {
  // ctx.query
  // ctx.request.body
  // ctx.get()

  // ctx.body=xxx
  // ctx.set('Cache-Control','no-cache')
  // ctx.status
})

let server = app.listen(4000, function () {})